/// @tags: Presum
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int maxn = 2e5 + 3, mod = 998244353, maxm = 1e7 + maxn;

int n, m, l, r;
int a[maxn], disc[maxn], buk[maxn], sum[maxn];
int fac[maxm], ifac[maxm];

inline LL qpow(LL base, int exp = mod - 2) {
  LL res = 1;
  for (; exp; exp >>= 1, base = base * base % mod)
    if (exp & 1) res = res * base % mod;
  return res;
}

inline void prework() {
  fac[0] = 1;
  for (rint i = 1; i < maxm; ++i) fac[i] = (LL)fac[i - 1] * i % mod;
  ifac[maxm - 1] = qpow(fac[maxm - 1], mod - 2);
  for (rint i = maxm - 2; i >= 0; --i) ifac[i] = (LL)ifac[i + 1] * (i + 1) % mod;
}

inline int main() {
  prework();
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> m >> l >> r;
    memset(buk, 0, sizeof(int) * (n + 3));
    memset(sum, 0, sizeof(int) * (n + 3));
    int fact = fac[n + m], overflow = r - l + 1, ans = 1;
    for (rint i = 1; i <= n; ++i) {
      cin >> disc[i];
      a[i] = disc[i];
    }
    std::sort(disc + 1, disc + n + 1);
    *disc = std::unique(disc + 1, disc + n + 1) - disc - 1;
    for (rint i = 1; i <= *disc; ++i) overflow -= (l <= disc[i] && disc[i] <= r);
    for (rint i = 1; i <= n; ++i) {
      a[i] = std::lower_bound(disc + 1, disc + *disc + 1, a[i]) - disc;
      if (l <= disc[a[i]] && disc[a[i]] <= r) buk[a[i]]++;
      sum[a[i]]++;
      ans = (LL)ans * sum[a[i]] % mod;
    }
    std::sort(buk + 1, buk + *disc + 1);
    int zero = 0;
    for (rint i = 1; i <= *disc; ++i)
      if (buk[i] == 0) zero = i;
    for (rint i = 1; i <= *disc - zero; ++i) buk[i] = buk[i + zero] % mod;
    n = *disc - zero;
    for (rint i = 0; i < n; ++i) {
      if (buk[i + 1] == buk[i]) continue;
      if ((LL)(buk[i + 1] - buk[i]) * (i + overflow) <= m) {
        m -= (buk[i + 1] - buk[i]) * (i + overflow);
        ans = (LL)ans * qpow((LL)fac[buk[i + 1]] * ifac[buk[i]] % mod, i + overflow) % mod;
      } else {
        int x = m / (i + overflow);
        ans = (LL)ans * qpow((LL)fac[buk[i] + x] * ifac[buk[i]] % mod, i + overflow) % mod;
        ans = (LL)ans * qpow(buk[i] + x + 1, m % (i + overflow)) % mod;
        m = 0;
        break;
      }
    }
    if (m > 0) {
      int x = m / (r - l + 1);
      ans = (LL)ans * qpow((LL)fac[buk[n] + x] * ifac[buk[n]] % mod, r - l + 1) % mod;
      ans = (LL)ans * qpow(buk[n] + x + 1, m % (r - l + 1)) % mod;
    }
    cout << (LL)fact * qpow(ans) % mod << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P4561 [JXOI2018] 排序问题.in", "r", stdin);
  freopen("P4561 [JXOI2018] 排序问题.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
